package com.lcxw.hxzbapi.controller.giftandcubecontroller;

import com.alibaba.fastjson.JSONObject;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lcxw.hxzbapi.entity.response.Response;

@RestController
@RequestMapping("/api/giftBag")
@CrossOrigin
@Slf4j
public class GiftBagController {

    @Resource
    GiftBagRealization giftBagRealization;

    /**
     *   1、获取用户背包中的所有礼物
     */
    @PostMapping("/getAll")
    public Response getAllGiftBag(@RequestBody JSONObject requestParams){
        long userId = Long.parseLong(requestParams.getString("userId"));
        List<JSONObject> data = null;
        try {
            data = giftBagRealization.getAllGiftBag(userId);
        } catch (Exception e) {
            return Response.dbFail(log,"operate gift or giftBag");
        }
        return Response.ok(data);
    }

}
